<script setup>
import { useConfirmModal } from '@/store/xmgl.js';
import { useWatch } from '@/hooks/useWatch';
const props = defineProps({
  open: { type: Boolean, default: () => false },
  msg: { type: String, default: () => '' },
});
const confirmModalStore = useConfirmModal();
const { displayCM } = storeToRefs(confirmModalStore);
const openModal = ref(props.open);
const emit = defineEmits(['openChange']);
const handleClick = () => {
  openModal.value = false;
  confirmModalStore.setDisplayCM(false);
  emit('openChange', false);
};
useWatch(displayCM, n => {
  openModal.value = n;
});
useWatch(
  () => props.open,
  n => (openModal.value = n),
);
</script>

<template>
  <el-dialog
    :visible.sync="openModal"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :append-to-body="true"
    width="25vw"
  >
    <div class="u-df-ct u-fd-col">
      <img src="@/assets/images/hint.svg" style="width: 85px" alt="" />
      <div class="u-prim-text u-fs20" style="margin: 20px auto 30px">{{ msg }}</div>
      <el-button type="primary" @click="handleClick">确 定</el-button>
    </div>
  </el-dialog>
</template>

<style lang="scss" scoped>
::v-deep .el-dialog {
  background: unset;
}
::v-deep .el-dialog__header {
  display: none;
}
::v-deep .el-dialog__body {
  border-radius: 6px;
  border: 1px solid #4d5677;
  background-color: #fff;
}
</style>
